<?php
load_ctl("Common");
class IndexController extends CommonController
{ 
	function init(){
		parent::init();
		load_model('Article');
		$this->article = new Article();
		load_model('Tag');
		$this->tag = new Tag();
    }
	public function indexAction(){
		//使用页面缓存
		load_inc("pagecache.class");
		$cache = new PageCache(BLOG_ROOT_DIR."/html/","index.html",10,true);
		if(!$cache->CheckCache()){//更新缓存
			ob_clean();
			ob_start();
			ob_implicit_flush(0);
			
			$this->view->webTitle='';
			$this->view->headTitle='Welcome to ph?\'s Blog';
			$this->view->index_article = $this->article->get_article_lists('where b.class_if_show=1','order by art_put_time desc','limit 10');
			$this->view->tags = $this->tag->get_tag_list();
			$this->view->links = array();
			echo $this->view->render('index.phtml');
			
			$length = ob_get_length();
			$content = ob_get_contents();
			$cache->UpdateCache($content,$length);
			ob_end_clean();
		}
		//直接使用html
		//改变模板文件位置
		$this->view->setScriptPath(BLOG_ROOT_DIR.'/html/');
		echo $this->view->render('index.html');    
	}
	
	public function noRouteAction(){
		$this->_redirect('/');
	}
}
?>